<!--
 * @Author: wang_sheshe
 * @Date: 2021-05-24 16:18:35
 * @LastEditTime: 2021-07-10 15:57:46
 * @Description: 试验记录
-->
<template>
    <div id="bileiqi_page">
        <!-- 折叠面板 -->
        <div>
            <van-cell-group :border="false">
                <van-cell :border="false" title="试验专业：" :value="experiData.testMajor"></van-cell>
                <van-cell :border="false" title="试验性质：" :value="experiData.testNature"></van-cell>
                <van-cell :border="false" title="试验日期：" :value="showDate(experiData.testDate)"></van-cell>
                <van-cell :border="false" title="所属大馈线：" :value="experiData.belongToFeeder"></van-cell>
                <van-cell :border="false" title="设备类型：" :value="experiData.deviceType"></van-cell>
                <van-cell :border="false" title="电站/线路：" :value="experiData.substationName"></van-cell>
                <van-cell :border="false" title="录入人：" :value="experiData.copyPerson"></van-cell>
                <van-cell :border="false" title="试验结论：" :value="experiData.testConclusion"></van-cell>
                <van-cell :border="false" title="附件：">
                    <template slot="default" @click="download">
                        <van-image width="40" height="40" :src="icon.pic"/>
                    </template>
                </van-cell>
            </van-cell-group> 
        </div>
    </div>
</template>
<script type="text/javascript">
import {getTestRecord} from '../../api/tourTask';
import Utils from '@/utils/util'
export default {
    name: "bileiqiCopy",
    components: {
       
    },
    props:{
        deviceinfo:{
            type:Object,
            default: function() {
                return {}
            }
        }
    },
    data() {
        return {
            // 智能表计绑定的数据
            text:"",
            icon: {
                pic: require("@/assets/img/mainIndex/defect.png")
            },
            //试验数据
            experiData: {
                // testMajor: "例检",//试验专业
                // testNature:"电气",//试验性质
                // testDate: "2021-4-4 13:30:00",//试验日期
                // belongToFeeder: "合格,可以投运",//所属大馈线
                // deviceType: "主变压器",//设备类型
                // substationName:"张家港变",//电站/线路
                // copyPersonId: "张为民",//录入人
                // testConclusion: "合格",//试验结论
                // //补充字段
                // attach: ""
            },
            userInfo: {},
            deviceInfo:this.deviceinfo,
            pageNum: 1,
            pageSize: 10,
            
        }
    },
    created(){
        var userInfo = localStorage.getItem("userInfo");
        this.userInfo = JSON.parse(userInfo);
        this.getTestRecord();
    },
    computed: {
        showDate() {
            return function(val) {
                if(val) {
                   return  Utils.DateUtil.getFormatDateByLong(val,'yyyy-MM-dd hh:mm:ss')
                }
                return "";
            }
        }
    },
    mounted() {
     
    },
    methods: {
        //下载附件
        download() {

        },
        /**
        * @description: 查询试验记录
        */
        getTestRecord() {
            var self = this
            this.$toast.loading({
                duration: 0,//展示时长 0不会消失
                message: "查询试验记录...",
                forbidClick: true,//是否禁止背景点击
                overlay: true//是否显示背景遮罩层
            })
            var params = {
                deviceId: "175680146",
                //deviceId: this.deviceInfo.deviceId,//设备类型
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                userId: this.userInfo.userId,//用户id
                roleCode: "",//用户角色
            }
            getTestRecord(params).then(function(res) {
                self.$Toast.clear()
                if(res.success){
                    self.$Toast.success(res.msg)
                    self.experiData = res.data[0];
                }else{
                    self.$Toast.fail(res.msg)
                }
            }).catch(err => {
                self.$toast.clear()
                self.$Toast.fail(err)
            });
        },
    },
}
</script>
<style scoped>
#bileiqi_page {
    width: 100%;
    height: 100%;   
    padding-bottom: 0;
    background: #fff;
}
#bileiqi_page /deep/ .van-field__label {
    width: 120px;
}
.line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.line .unit {
    width: 20px;
}
.padding_div{
    padding: 10px 16px;
    color: #646566;
}
</style>